package dp;

import java.util.Arrays;
import java.util.Scanner;

public class 游戏中的学问 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        long P = scanner.nextLong();
        long[][] dp = new long[N + 1][K + 1];
        dp[3][1] = 2;

        for (int i = 4; i <= N; i++) {
            for (int j = 1; 3 * j <= i && j <= K; j++) {
                dp[i][j] = dp[i - 1][j] * (i - 1) % P;
                dp[i][j] = (dp[i][j] + dp[i - 3][j - 1] * (i - 1) * (i - 2))%P;
            }
        }
        print(dp);
        System.out.println(dp[N][K]);
    }

    private static void print(long[][] map) {
        System.out.println("====");
        for (long[] line : map) {
            System.out.println(Arrays.toString(line));
        }
        System.out.println("====");
    }

}
